﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Tayninh2011
{
    public sealed partial class FrmSingleton : Form
    {
        private static readonly FrmSingleton myReadonlyForm = new FrmSingleton();
        private FrmSingleton()
        {
            InitializeComponent();
        }
        public static FrmSingleton myForm
        {
            get { return myReadonlyForm; }
        }
        public new void Show()
        {
            if (isShown)
            {
                base.Show();
            }
            else
            {
                base.Show();
                isShown = true;
            }
        }
        private static bool isShown = false;
        static FrmSingleton()
        {
            myForm.FormClosing += new FormClosingEventHandler(frmLogin_FormClosing);
        }
        private static void frmLogin_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            isShown = false;
            myForm.Hide();
        }
    }
}
